import { reactive, onMounted } from 'vue'
import { api as viewerApi } from 'v-viewer'
import { alter } from '@/common/base'

const YPmove = () => {
	let mpos = reactive({ w: window.pageXOffset, h: window.pageYOffset })
	onMounted(() => {
		window.addEventListener('mousemove', (e) => {
			mpos.w = e.pageX
			mpos.h = e.pageY
		})
	})
	return mpos
}

const imgPreview = (imgsArr) => {
	if (imgsArr && imgsArr.length > 0) {
		viewerApi({
			images: imgsArr
		})
	} else {
		alter({ type: 'alter-error', text: '暂无图片' })
	}
}
export { YPmove, imgPreview }
